<div class="row">
	<div class="col-lg-12">
    	<form method="get" action="index.php">
    	 <div class="form-group input-group col-lg-4" style="float:left;" >
         	<input type="hidden" name="page" value="user">
            <input
            	 value="<?php  if(isset($_GET['txtKey'])) echo $_GET['txtKey'];?>"
            	 name="txtKey"
            	 type="text" 
                 class="form-control">
            <span class="input-group-btn">
            	<button  type="submit" class="btn btn-primary" type="button"><i class="fa fa-search"></i></button>
            </span>
         </div>
         </form>
        <div class="form-group input-group col-lg-3" style="float:right;" >
        <form method="get" action="index.php">
        	<input type="hidden" name="page" value="user">
            <p class="col-md-4">
            <input 
            	value="<?php echo $ipp; ?>"
            	type="text" 
                name="ipp"
                class="form-control">
             </p>   
            
            	<input type="submit" class="btn btn-primary" name="btnGui" type="button" value="Change">
          
         </form>   
         </div>

    </div><!--.row-->
    <form method="post" action="">
    <div class="col-md-12">
        
            <div class="col-md-6 " style="margin-bottom:10px;" >
                
                 <input type="submit" name="btnDel" value="Delete" class="btn btn-danger" >
             </div>
         
         <div class="col-md-6" style="margin-bottom:10px;" >
            <a  class="btn btn-success pull-right" href="<?php echo $url; ?>index.php?page=user&action=add&form=1">Add new </a>
         </div>
    
    </div><!-- /.row -->
    <div class="col-lg-12">
        <div class="table-responsive">
        	
            <table class="table table-bordered table-hover table-striped">
                <thead>
                    <tr>
                        <th>#</th>
                        <th><input id="check-all" type="checkbox"></th>
                        <th>Username</th>
                        <th>E-mail</th>
                        <th>Fullname</th>
                        <th>Role</th>
                        <th>Sex</th>
                        <th>Phone</th>
                        <th>Address</th>
                        <th>Birthday</th>
                        <th>Status</th>
                        <th>Action</th>
                    </tr>
                </thead>
                <tbody>
                    <?php
						foreach($list_user as $key=>$item)
						{
							if(is_array($item))
							{
						
					?>
                    <tr <?php if(($key%2==0)) echo "class='success'"; else echo "class='danger'";  ?>>
                        <td><?php echo $item['id'] ?></td>
                        <td><input class="check-all" type="checkbox" name="cbitem[]" value="<?php echo $item['id'];?>"></td>
                        <td><?php echo $item['username'] ?></td>
                        <td><?php echo $item['email'] ?></td>
                        <td><?php echo $item['fullname'] ?></td>
                         <td style="text-align:center"><?php 
						    $sql_group="select * from tb_user_group where id=".$item["groupid"];
							$group=$lib->selectone($sql_group);
							if($group->title=='') echo "-"; else echo $group->title;
							
						?></td>
                        <td><?php if($item['sex']==1) echo "Nam"; else echo "Nữ"; ?></td>
                        <td><?php echo $item['phone'] ?></td>
                        <td><?php echo $item['address'] ?></td>
                        
                        <td><?php
							//echo $item['birthday'];
							if($item['birthday'] != '0000-00-00 00:00:00') 
								echo gmdate('d/m/Y', strtotime($item['birthday']) + 7*3600);
							else echo '-';
							
						 ?></td>
                       
                        <td  class="status">
							<?php 
								if($item['publish']==1) echo "<i class='glyphicon glyphicon-ok'></i>";  
								if($item['publish']==0) echo "<i class='glyphicon glyphicon-question-sign'></i>";
								if($item['publish']==2) echo "<i class='glyphicon glyphicon-lock'></i>";
							?>
                        </td>
                        <td class="action-f" style="text-align:center;">
                        	<a 
                            	href="<?php echo $url; ?>index.php?page=user&action=del&id=<?php echo $item['id'] ?>"
                                onClick="return confirm('Do you want to delete this record ?')"
                                >
                            	<i class="glyphicon glyphicon-remove"></i>
                            </a>
                            
                            <a href="<?php echo $url; ?>index.php?page=user&action=edit&form=1&id=<?php echo $item['id'] ?>">
                            	<i class="glyphicon glyphicon-pencil"></i>
                            </a>
                            
                        </td>
                    </tr>
                    <?php
							}
					   }
					?>
                   
                </tbody>
            </table>
            <div class="pagination"><?php $lib->viewpage($link); ?></div>
        </div>
    </div><!-- /.col-md-12 -->
    </form>
</div>
<!-- /.row -->
<script>
$(document).ready(function(e) {
 	/* ================ #CHECK-ALL =================== */
	$('#check-all').click(function(){
		
		if($(this).prop('checked')){
			$('.check-all').prop('checked', true).parent().parent().find('td').addClass('select');
		}
		else{
			$('.check-all').prop('checked', false).parent().parent().find('td').removeClass('select');
		}
	});
	$('.check-all').click(function(){
		if($(this).prop('checked') == false){
			$(this).parent().parent().find('td').removeClass('select');
			$('#check-all').prop('checked', false);
		}
		else{
			$(this).parent().parent().find('td').addClass('select');
		}
		if($('.check-all:checked').length == $('.check-all').length){
			$('#check-all').prop('checked', true);
		}
	});
});
	
</script>